/*
 * @Descripttion:
 * @version:
 * @Author: sueRimn
 * @Date: 2020-10-30 15:29:40
 * @LastEditors: sueRimn
 * @LastEditTime: 2020-11-14 18:25:59
 */
import request from '@/utils/request'
import store from '@/store/index'
const base = require('../../../env/index')
const URL = require('./demo')

// 夹带k_token
function addK_Token(data) {
    var token = {
        k_token: store.getters.k_token
    }
    Object.assign(data, token)
    return data
}

// 转换携带id URL
function checkHasID(url, data) {
    var reg = RegExp(/<[^<>]+>/g)
    if (reg.test(url)) {
        var arr = url.split('/')
        var id = arr[arr.length - 1].replace(/\<|\>/g, '').trim()
        var header = url.replace(/<[^<>]+>/g, '')
        return header + data[id]
    } else {
        return url
    }
}

export function get_UserInfo(data) {
    return request({
        url: base.question_url + checkHasID(URL.ADD_API, data),
        method: 'POST',
        headers: {},
        data: addK_Token(data)
    })
}

var str = 'api/v1/admin/zoom/recoverdel/<unid>'

var data = {
    unid: '123'
}

console.log(base.question_url + checkHasID(str, data))
